package com.flight.trans.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.flight.trans.R;
import com.flight.trans.base.BaseRecyclerAdapter;
import com.flight.trans.base.BaseViewHolder;
import com.flight.trans.bean.HandoverBean.HandoverData;
import com.flight.trans.http.GlideLoader;
import com.flight.trans.util.LogUtils;

import java.util.List;

/**
 * 进港入库交接
 */
public class EnterPortHandoverAdapter extends BaseRecyclerAdapter<HandoverData> {

    public EnterPortHandoverAdapter(Context mContext, List<HandoverData> mList) {
        super(mContext, mList);
    }

    @Override
    public int setContentView() {
        return R.layout.adapter_enter_port_handover;
    }

    @Override
    protected void bindData(BaseViewHolder holder, HandoverData data, int position) {
        LinearLayout mLlContainerItem = holder.findViewById(R.id.mLlContainerItem);
        TextView mTvContainerCount = holder.findViewById(R.id.mTvContainerCount);
        TextView mTvHaveTaskBag = holder.findViewById(R.id.mTvHaveTaskBag);
        TextView mTvInstructor = holder.findViewById(R.id.mTvInstructor);
        TextView mTvTransportTime = holder.findViewById(R.id.mTvTransportTime);
        TextView mTvTransWarehousingTime = holder.findViewById(R.id.mTvTransWarehousingTime);

        ImageView mIvDriverSign = holder.findViewById(R.id.mIvDriverSign);

        mTvContainerCount.setText(String.valueOf(data.getTransportCnt()));
        mTvHaveTaskBag.setText(mContext.getString(data.getHasBag() == 1 ? R.string.text_have : R.string.text_not));
        mTvInstructor.setText(mContext.getString(data.getInstructor() == 1 ? R.string.text_have : R.string.text_not));
        mTvTransportTime.setText(data.getDeliveryTime());
        mTvTransWarehousingTime.setText(data.getHandoverTime());

        LogUtils.e("图片" , data.getUrl());
        GlideLoader.loader(data.getUrl() , mIvDriverSign);

        setOnTextClickListener(mIvDriverSign, position);
        setOnItemClickListener(mLlContainerItem , position);
    }
}
